// pages/my-team-relationship/my-team-relationship.js
const apiurl = require('../../config').apiurl;
import { Pulibc } from '../../models/public.js'
const pulibc = new Pulibc();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    tenameNumber:'',
    order_sum:''
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.invite_one)
    let invite_one = options.invite_one
    this.getRelationship(invite_one)
  },

  // 获取二级关系
  getRelationship(invite_one){
    let page = this.data.page
    let key = wx.getStorageSync('key')
  
    let url = apiurl+'/invite/invite_two'
    wx.request({
      url: url,
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      method:'POST',
      data:{
        key,
        page,
        invite_one
      },success:data=>{
        var tenameNumber = data.data.datas.count_sum;
        let order_sum = data.data.datas.order_sum
        console.log(tenameNumber);
        console.log(data)
        this.setData({
         
          invite_two: data.data.datas.invite_two,
          tenameNumber: tenameNumber,
          order_sum: order_sum
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (wx.getStorageSync("key") == false) {
      wx.navigateTo({
        url: "../register/register"
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})